<button id="confirm_btn_id" style="display: none;" type="button" class="btn btn-danger" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo"></button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="exampleModalLabel">提示（自动安装jdk与配置环境变量）：</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label class="control-label">确定要一键安装jdk1.8吗？</label>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-" data-dismiss="modal">返回</button>
                <button type="button" class="btn btn-pridefaultmary" data-dismiss="modal" onclick="ok()">确认</button>
            </div>
        </div>
    </div>
</div>

<div class="col-md-3"></div>
<div id="jdk_vue" class="col-md-6">
    <ul class="list-group">
        <li class="list-group-item">
            <img @click="execQuick" src="../../images/cmd.png" style="height:30px;width:45px;float:right;margin-top:-5px;cursor:pointer;"/>
            jdk安装列表<span style="float:right">一键安装 - >&nbsp;&nbsp;&nbsp;</span>
        </li>
        <li class="list-group-item">
            <span class="badge">新</span>
            <button @click="jdkInstall" data-version="8" type="button" class="btn btn-default btn-lg" style="float:right;margin-top:10px;height:30px;font-size:14px;line-height:10px;">安装</button>
            <img src="../../images/jdk1.8_64.png" style="height: 42px; width: 180px;"/>
        </li>
        <li class="list-group-item">
            <button @click="jdkInstall" data-version="7" type="button" class="btn btn-default btn-lg" style="float:right;margin-top:10px;margin-right: 25px;height:30px;font-size:14px;line-height:10px;">安装</button>
            <img src="../../images/jdk1.7_64.png" style="height: 42px; width: 180px;"/>
        </li>
        <li class="list-group-item">
            <button @click="jdkInstall" data-version="6" type="button" class="btn btn-default btn-lg" style="float:right;margin-top:10px;margin-right: 25px;height:30px;font-size:14px;line-height:10px;">安装</button>
            <img src="../../images/jdk1.6_64.png" style="height: 42px; width: 180px;"/>
        </li>
        <li class="list-group-item">
            <img src="../../images/text.png" style="height:20px;width:15px;"/>&nbsp;<a @click="openJdkEnvironmentTxt" style="cursor:pointer;">java环境变量配置文档</a>
        </li>
    </ul>
</div>
<div class="col-md-3"></div>
<script>
    var jdk_vue = new Vue({
        el:"#jdk_vue"
        ,data:{
            items:{}
        }
        ,methods:{
            execQuick:function(){
                $(".btn-pridefaultmary").attr("onclick","ok()");
                $("#confirm_btn_id").click();
                $("#exampleModalLabel").text("提示（自动安装jdk与配置环境变量）：");
                $(".control-label").text("确定要一键安装jdk1.8吗？");
            },
            jdkInstall:function(v){
                var version = $(v.target).attr("data-version");
                $(".btn-pridefaultmary").attr("onclick","confirmInstall('"+version+"')");
                $("#confirm_btn_id").click();
                $("#exampleModalLabel").text("提示：");
                $(".control-label").text("确定安装该应用程序吗？");
            },
            openJdkEnvironmentTxt:function(){
                $.get("java/openJdkEnvironmentTxt",function(resp){
                    /*console.log(resp);*/
                });
            }
        }
    });

    function executeCmd(type){
        if(type==="0"){//jdk一键安装配置环境变量
            $.get("java/jdkQuickInstall",function(resp){
                /*console.log(resp);*/
            });
        }else if("6,7,8".indexOf(type)!=-1){
            $.get("java/jdkInstall?version="+type,function(resp){
                /*console.log(resp);*/
            });
        }
    }

    function ok(){
        executeCmd("0");
    }

    function confirmInstall(version){
        var count = 0;
        var speck = "";
        var times = version==6?3:8;
        executeCmd(version);
        MsgAlert.confirm("安装程序启动中",function(){},false);
        var interID = setInterval(function(){
            if(count==times){
                clearInterval(interID);
                $("#myConfirm").find(".close").click();
            }
            speck+=".";
            $("#myConfirm").find(".modal-body").text("安装程序启动中"+speck);
            count++;
        },1000);
    }
</script>
<script src="../../js/jquery-2.1.1.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>